package operations;


import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOperations {
    @Override
    public void work(BookList bookList) {
//        System.out.println("查找图书");
        int currentsize = bookList.getUsedSize();
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要查找的图书的名字");
        String bookname = scanner.nextLine();
        for (int i =0; i < currentsize; i++){
            Book book = bookList.getBook(i);
            if (book.getName().equals(bookname)){
                System.out.println("找到了这本书");
                System.out.println(book);//重写了tostring方法会自动调用 NB
                return;
            }
        }
        System.out.println("没有找到这本书");
    }
}
